package com.example.tree.domain.dto;

import io.swagger.v3.oas.annotations.media.Schema;
import jakarta.validation.constraints.*;
import lombok.Data;
import org.hibernate.validator.constraints.URL;

import java.math.BigDecimal;
import java.time.LocalDateTime;
import java.util.List;

/**
 * 古树信息传输对象（DTO）
 * 最后更新时间：2025-06-26 
 */
@Data
@Schema(description = "古树信息传输对象")
public class TreeDTO {

    @Schema(description = "古树唯一ID", example = "123")
    @Positive(message = "古树ID必须为正整数")
    private Integer treeId;

    @Schema(description = "古树中文名", example = "轩辕柏")
    @NotBlank(message = "中文名不能为空")
    @Size(max = 50, message = "中文名长度不能超过50字符")
    private String chineseName;

    @Schema(description = "拉丁学名（国际命名规范）", example = "Platycladus orientalis", nullable = true)
    @Size(max = 100, message = "拉丁学名长度不能超过100字符")
    private String scientificName;

    @Schema(description = "植物科名", example = "柏科", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotBlank(message = "科名不能为空")
    @Size(max = 50, message = "科名长度不能超过50字符")
    private String familyName;

    @Schema(description = "植物属名", example = "侧柏属", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotBlank(message = "属名不能为空")
    @Size(max = 50, message = "属名长度不能超过50字符")
    private String genusName;

    @Schema(description = "树龄（年），0表示未知", example = "1200", minimum = "0", maximum = "65535")
    @Min(value = 0, message = "树龄最小为0年")
    @Max(value = 65535, message = "树龄超过smallint上限")
    private Integer estimatedAge;

    @Schema(description = "保护等级（1-5级，1为最高）", example = "3", allowableValues = {"1", "2", "3", "4", "5"})
    @NotNull(message = "保护等级不能为空")
    @Min(1) @Max(5)
    private Integer protectionLevel;

    @Schema(description = "经度（WGS84坐标系）", example = "116.3912345", pattern = "^\\-?\\d{1,3}\\.\\d{7}$")
    @Digits(integer = 3, fraction = 7, message = "经度格式应为xxx.xxxxxxx")
    private BigDecimal gpsLongitude;

    @Schema(description = "纬度（WGS84坐标系）", example = "39.9076543", pattern = "^\\-?\\d{1,2}\\.\\d{7}$")
    @Digits(integer = 2, fraction = 7, message = "纬度格式应为xx.xxxxxxx")
    private BigDecimal gpsLatitude;

    @Schema(description = "省级行政区划代码（6-12位数字）", example = "110000", pattern = "\\d{6,12}")
    @Pattern(regexp = "^\\d{6,12}$", message = "省级区划编号需为6-12位数字")
    private String provinceCode;

    @Schema(description = "省级行政区名称", example = "北京市", maxLength = 32)
    @Size(max = 32, message = "省级名称长度不能超过32字符")
    private String provinceName;

    @Schema(description = "市级行政区划代码（6-12位数字）", example = "110100", pattern = "\\d{6,12}")
    @Pattern(regexp = "^\\d{6,12}$", message = "市级区划编号需为6-12位数字")
    private String cityCode;

    @Schema(description = "市级行政区名称", example = "市辖区", maxLength = 32)
    @Size(max = 32, message = "市级名称长度不能超过32字符")
    private String cityName;

    @Schema(description = "区级行政区划代码（6-12位数字）", example = "110101", pattern = "\\d{6,12}")
    @Pattern(regexp = "^\\d{6,12}$", message = "区级区划编号需为6-12位数字")
    private String districtCode;

    @Schema(description = "区级行政区名称", example = "东城区", maxLength = 32)
    @Size(max = 32, message = "区级名称长度不能超过32字符")
    private String districtName;

    @Schema(description = "详细地理位置描述", example = "北京市东城区景山前街4号故宫内", requiredMode = Schema.RequiredMode.REQUIRED)
    @NotBlank(message = "地理位置不能为空")
    @Size(max = 1000, message = "地理位置描述过长")
    private String locationAddress;

    @Schema(description = "古树历史或特征描述", example = "传为黄帝亲手种植，树龄约5000年", maxLength = 2000)
    @Size(max = 2000, message = "描述内容超过2000字符限制")
    private String description;

    @Schema(description = "古树图片列表", example = "[\"http://example.com/image1.jpg\", \"http://example.com/image2.jpg\"]")
    private List<String> images;


}